/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.verify;

import picounit.features.base.FileReader;
import picounit.verify.FileConstraints;
import picounit.verify.ReasonCapturer;
import picounit.verify.constraint.FileConstraint;

import java.io.File;

public class DefaultFileConstraints extends Constraints
	implements FileConstraints {

	private final FileReader fileReader = new FileReader();

	public DefaultFileConstraints(Evaluator evaluator) {
		super(evaluator);
	}

	public ReasonCapturer isEqualTo(File equalTo) {
		return passes(constraintFactory.equalTo(equalTo, modifier(), stringer()));
	}

	public ReasonCapturer isDifferentTo(File differentTo) {
		return passes(constraintFactory.differentTo(differentTo, modifier(), stringer()));
	}

	public ReasonCapturer isGreaterThan(File greaterThan) {
		return passes(constraintFactory.greaterThan(greaterThan, modifier()));
	}

	public ReasonCapturer isGreaterThanOrEqualTo(File greaterThanOrEqualTo) {
		return passes(constraintFactory.greaterThanOrEqualTo(greaterThanOrEqualTo, modifier()));
	}

	public ReasonCapturer isLessThan(File lessThan) {
		return passes(constraintFactory.lessThan(lessThan, modifier()));
	}

	public ReasonCapturer isLessThanOrEqualTo(File lessThanOrEqualTo) {
		return passes(constraintFactory.lessThanOrEqualTo(lessThanOrEqualTo, modifier()));
	}

	public ReasonCapturer isTheSameTypeAs(File sameTypeAs) {
		return passes(new SameFileType(sameTypeAs));
	}

	public ReasonCapturer hasTheSameContentsAs(File sameContentsAs) {
		return passes(new SameFileContents(sameContentsAs, fileReader));
	}

	public ReasonCapturer passes(FileConstraint fileConstraint) {
		return passes(createDelegate(File.class, fileConstraint));
	}
}
